<script setup>
import {ref} from "vue";
import {
  jobConcurrentStatusList,
  jobGroupStatusList,
  jobMisfirePolicyTypeList,
  jobStatusList,
  operateLogStatusList
} from "@/enum/enum";
import {getSysJob} from "@/api/monitor/sys_job";

const modalRef = ref();
const formData = ref({
  jobId: undefined,
})

const open = async (jobId) => {
  const {data} = await getSysJob(jobId);
  formData.value = {
    ...data
  }
  modalRef.value.handleOpen()
}

defineExpose({open})
</script>

<template>
  <dialog-form ref="modalRef" modalTitle="任务详情" modalWidth="1000px" :enable-submit="false" cancel-text="关闭">
    <el-descriptions
        direction="horizontal"
        :column="2"
        border>
      <el-descriptions-item label="任务编号">{{formData.jobId}}</el-descriptions-item>
      <el-descriptions-item label="任务分组">
        <el-tag :type="jobGroupStatusList[formData.jobGroup].type">{{ jobGroupStatusList[formData.jobGroup].label }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="任务名称">{{formData.jobName}}</el-descriptions-item>
      <el-descriptions-item label="创建时间">{{formData.createTime}}</el-descriptions-item>
      <el-descriptions-item label="cron表达式">{{formData.cronExp}}</el-descriptions-item>
      <el-descriptions-item label="下次执行时间">{{formData.nextValidTime}}</el-descriptions-item>
      <el-descriptions-item label="调用目标方法" :span="2">{{formData.invokeTarget}}</el-descriptions-item>
      <el-descriptions-item label="任务状态">
        <el-tag :type="jobStatusList[formData.status].type">{{ jobStatusList[formData.status].label }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="是否并发">
        <el-tag :type="jobConcurrentStatusList[formData.concurrent].type">{{ jobConcurrentStatusList[formData.concurrent].label }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="执行策略" :span="3">
        <el-tag :type="jobMisfirePolicyTypeList[formData.misfirePolicy].type">{{ jobMisfirePolicyTypeList[formData.misfirePolicy].label }}</el-tag>
      </el-descriptions-item>
    </el-descriptions>
  </dialog-form>
</template>

<style scoped lang="scss">

</style>
